﻿@using System.Diagnostics;
@using System.Collections;
@using System.Reflection;
@using System.Runtime.Versioning;
@using NewLife.Common;
@{
    Layout = NewLife.Cube.Setting.Current.Layout;

    ViewBag.Title = "服务器变量列表";
    var Act = ViewBag.Act;

    var asm = Assembly.GetExecutingAssembly();
    var att = asm.GetCustomAttribute<TargetFrameworkAttribute>();
    var ver = att.FrameworkDisplayName ?? att.FrameworkName;
    var req = HttpContext.Current.Request;
}            

<div class="kt-portlet kt-portlet--mobile">
    <div class="kt-portlet__head">
        <div class="kt-portlet__head-label">
                <span class="kt-portlet__head-icon">
                    <i class="la la-gear"></i>
                </span>
                <h3 class="kt-portlet__head-title">服务器变量列表</h3>
        </div>
    </div>  
    <div class="kt-portlet__body">
        <table class="table table-bordered table-hover table-striped table-condensed">
            <tr>
                <th>名称</th>
                <th>数值</th>
            </tr>
            @foreach (var key in Request.ServerVariables.AllKeys)
            {
                var v = Request.ServerVariables[key];
                v = v.Replace("\r\n", "</br>");
                if (key.EqualIgnoreCase("HTTP_COOKIE")) { v = v.Replace(";", "</br>"); }
                <tr>
                    <td>@key</td>
                    <td>@Html.Raw(v)</td>
                </tr>
            }
        </table>
    </div>
</div>     

<div class="kt-portlet kt-portlet--last kt-portlet--mobile">
    <div class="kt-portlet__head">
        <div class="kt-portlet__head-label">
                <span class="kt-portlet__head-icon">
                    <i class="la la-gear"></i>
                </span>
                <h3 class="kt-portlet__head-title">Request变量列表&nbsp;&nbsp;&nbsp;&nbsp;@req.GetType().FullName</h3>
        </div>
    </div>
    <div class="kt-portlet__body">
        <table class="table table-bordered table-hover table-striped table-condensed">
            <tr>
                <th>名称</th>
                <th>数值</th>
            </tr>
            @foreach (var pi in req.GetType().GetProperties())
            {
                if (pi.GetIndexParameters().Length > 0 || (pi.PropertyType != typeof(String) && pi.PropertyType != typeof(Uri))) { continue; }
                var v = req.GetValue(pi) + "";
                v = v.Replace("\r\n", "</br>");
                <tr>
                    <td>@pi.Name</td>
                    <td>@Html.Raw(v)</td>
                </tr>
            }
        </table>
    </div>
</div>